package com.sunjob.mroresumeproject.dao;

import com.sunjob.common.domain.mroresume.WHBus;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository//声明持久层
public interface WHBusMapper {
    @Select("select count(*) from bus_resume where status=1 ")
    int querycount();

    @Select("select * from bus_resume where status=1 limit #{pages},#{size} ")
    List<WHBus> queryWHbus(int pages, int size);

    @Select("select * from bus_resume where Instance_id=#{Instance_id}  and status=1")
    @Results({
            @Result(property = "Instance_id",column = "Instance_id"),
            @Result(property = "Instance_name",column = "Instance_name"),
            @Result(property = "Instance_brand",column = "Instance_brand"),
            @Result(property = "Instance_vender",column = "Instance_vender"),
            @Result(property = "Instance_mileage",column = "Instance_mileage"),
            @Result(property = "time",column = "time"),
            @Result(property = "create_date",column = "create_date")

    })
    List<WHBus> queryWHBus2(String Instance_id);

    @Insert("insert into bus_resume values(#{Instance_id},#{Instance_name},#{Instance_brand},#{Instance_vender},#{Instance_mileage},#{time},#{create_date},#{status})")
    void insertBus(WHBus whBus);


    @Select("select * from bus_resume where Instance_id=#{Instance_id} and status=1")
    @Results({
            @Result(property = "Instance_id",column = "Instance_id"),
            @Result(property = "Instance_name",column = "Instance_name"),
            @Result(property = "Instance_brand",column = "Instance_brand"),
            @Result(property = "Instance_vender",column = "Instance_vender"),
            @Result(property = "Instance_mileage",column = "Instance_mileage"),
            @Result(property = "time",column = "time"),
            @Result(property = "create_date",column = "create_date")

    })
    List<WHBus> queryWHBusone(Long Instance_id);

    @Update("update bus_resume set Instance_name=#{Instance_name},Instance_brand=#{Instance_brand},Instance_vender=#{Instance_vender},Instance_mileage=#{Instance_mileage},time=#{time},create_date=#{create_date}")
    void updateWHBus(WHBus whBus);

    @Update("update bus_resume set statues=0 where Instance_id=#{Instance_id}")
    void deleteWHBus(String Instance_id);
    @Update("update bus_resume set statues=0 where Instance_id=#{s}")
    void deleteWHBusone(String s);
}
